-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[libc++] Refactor the configuration macros to being always defined #112094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
c44ba76
to
131d843
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThis is a follow-up to #89178. This updates the Patch is 335.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112094.diff 210 Files Affected:
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 75c926f5432aea..bb03b443178861 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -741,24 +741,24 @@ config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE)
config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
-config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
-config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
-config_define_if_not(LIBCXX_HAS_TERMINAL_AVAILABLE _LIBCPP_HAS_NO_TERMINAL)
+config_define(${LIBCXX_ENABLE_THREADS} _LIBCPP_HAS_THREADS)
+config_define(${LIBCXX_ENABLE_MONOTONIC_CLOCK} _LIBCPP_HAS_MONOTONIC_CLOCK)
+config_define(${LIBCXX_HAS_TERMINAL_AVAILABLE} _LIBCPP_HAS_TERMINAL)
if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default")
config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)
endif()
config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32)
-config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
+config_define(${LIBCXX_HAS_MUSL_LIBC} _LIBCPP_HAS_MUSL_LIBC)
config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
-config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM)
-config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
-config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
-config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
-config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
-config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
-config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+config_define(${LIBCXX_ENABLE_FILESYSTEM} _LIBCPP_HAS_FILESYSTEM)
+config_define(${LIBCXX_ENABLE_RANDOM_DEVICE} _LIBCPP_HAS_RANDOM_DEVICE)
+config_define(${LIBCXX_ENABLE_LOCALIZATION} _LIBCPP_HAS_LOCALIZATION)
+config_define(${LIBCXX_ENABLE_UNICODE} _LIBCPP_HAS_UNICODE)
+config_define(${LIBCXX_ENABLE_WIDE_CHARACTERS} _LIBCPP_HAS_WIDE_CHARACTERS)
+config_define(${LIBCXX_ENABLE_TIME_ZONE_DATABASE} _LIBCPP_HAS_TIME_ZONE_DATABASE)
+config_define(${LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS} _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS)
if (LIBCXX_ENABLE_ASSERTIONS)
message(DEPRECATION "LIBCXX_ENABLE_ASSERTIONS is deprecated and will be removed in LLVM 20. Please use LIBCXX_HARDENING_MODE instead.")
diff --git a/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst b/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
index e7f3de54e6782a..d103c49e25952f 100644
--- a/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
+++ b/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
@@ -45,9 +45,9 @@ API but leaves out the implementation.
Threading Configuration Macros
==============================
-**_LIBCPP_HAS_NO_THREADS**
- This macro is defined when libc++ is built without threading support. It
- should not be manually defined by the user.
+**_LIBCPP_HAS_THREADS**
+ This macro is set to 1 when libc++ is built with threading support. Otherwise
+ it is set to 0. It should not be manually defined by the user.
**_LIBCPP_HAS_THREAD_API_EXTERNAL**
This macro is defined when libc++ should use the ``<__external_threading>``
diff --git a/libcxx/include/__algorithm/find.h b/libcxx/include/__algorithm/find.h
index 6f23ec3f6fc69d..14b8a7804887b0 100644
--- a/libcxx/include/__algorithm/find.h
+++ b/libcxx/include/__algorithm/find.h
@@ -29,7 +29,7 @@
#include <__utility/move.h>
#include <limits>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -65,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
return __last;
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
template <class _Tp,
class _Up,
class _Proj,
@@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
return __ret;
return __last;
}
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // _LIBCPP_HAS_WIDE_CHARACTERS
// TODO: This should also be possible to get right with different signedness
// cast integral types to allow vectorization
diff --git a/libcxx/include/__algorithm/lexicographical_compare.h b/libcxx/include/__algorithm/lexicographical_compare.h
index 1de3ca13e1b45c..ebe7e3b56a292e 100644
--- a/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/libcxx/include/__algorithm/lexicographical_compare.h
@@ -26,7 +26,7 @@
#include <__type_traits/is_trivially_lexicographically_comparable.h>
#include <__type_traits/is_volatile.h>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -78,14 +78,14 @@ __lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __las
return __last1 - __first1 < __last2 - __first2;
return __res < 0;
}
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# if _LIBCPP_HAS_WIDE_CHARACTERS
else if constexpr (is_same<__remove_cv_t<_Tp>, wchar_t>::value) {
auto __res = std::__constexpr_wmemcmp(__first1, __first2, std::min(__last1 - __first1, __last2 - __first2));
if (__res == 0)
return __last1 - __first1 < __last2 - __first2;
return __res < 0;
}
-# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# endif // _LIBCPP_HAS_WIDE_CHARACTERS
else {
auto __res = std::mismatch(__first1, __last1, __first2, __last2);
if (__res.second == __last2)
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 0b2137dee2f77e..5490d8049bf7c8 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -894,7 +894,7 @@ template <class _Comp, class _RandomAccessIterator>
void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
#endif
extern template _LIBCPP_EXPORTED_FROM_ABI void
@@ -941,7 +941,7 @@ template <class _Type>
using __sort_is_specialized_in_library = __is_any_of<
_Type,
char,
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
wchar_t,
#endif
signed char,
diff --git a/libcxx/include/__atomic/aliases.h b/libcxx/include/__atomic/aliases.h
index afc64eaaa69e7b..605c524a3fbc38 100644
--- a/libcxx/include/__atomic/aliases.h
+++ b/libcxx/include/__atomic/aliases.h
@@ -42,7 +42,7 @@ using atomic_char8_t = atomic<char8_t>;
#endif
using atomic_char16_t = atomic<char16_t>;
using atomic_char32_t = atomic<char32_t>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
using atomic_wchar_t = atomic<wchar_t>;
#endif
diff --git a/libcxx/include/__atomic/atomic_sync.h b/libcxx/include/__atomic/atomic_sync.h
index aaf81f58731a98..08f3497fef9f45 100644
--- a/libcxx/include/__atomic/atomic_sync.h
+++ b/libcxx/include/__atomic/atomic_sync.h
@@ -69,7 +69,7 @@ struct __atomic_wait_poll_impl {
}
};
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if _LIBCPP_HAS_THREADS
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
@@ -163,7 +163,7 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _
std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a));
}
-#else // _LIBCPP_HAS_NO_THREADS
+#else // _LIBCPP_HAS_THREADS
template <class _AtomicWaitable, class _Poll>
_LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) {
@@ -177,7 +177,7 @@ _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {}
template <class _AtomicWaitable>
_LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {}
-#endif // _LIBCPP_HAS_NO_THREADS
+#endif // _LIBCPP_HAS_THREADS
template <typename _Tp>
_LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
diff --git a/libcxx/include/__chrono/convert_to_tm.h b/libcxx/include/__chrono/convert_to_tm.h
index 3a51019b80784a..5f1b2632f629a5 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -180,8 +180,7 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
// Has no time information.
} else if constexpr (same_as<_ChronoT, chrono::local_info>) {
// Has no time information.
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
} else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) {
return std::__convert_to_tm<_Tm>(
chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()});
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 8389e2cbf9e595..c1b57209b938d9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -12,7 +12,7 @@
#include <__config>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#if _LIBCPP_HAS_LOCALIZATION
# include <__algorithm/ranges_copy.h>
# include <__chrono/calendar.h>
@@ -143,8 +143,7 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<
__value.fractional_width);
}
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
template <class _CharT, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI void
__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
@@ -156,8 +155,7 @@ template <class _Tp>
consteval bool __use_fraction() {
if constexpr (__is_time_point<_Tp>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
# endif
@@ -232,7 +230,7 @@ _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const
# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
if constexpr (same_as<_Tp, chrono::sys_info>)
return {__value.abbrev, __value.offset};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return __formatter::__convert_to_time_zone(__value.get_info());
# endif
@@ -450,7 +448,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
# endif
@@ -500,7 +498,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
# endif
@@ -550,7 +548,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
# endif
@@ -600,7 +598,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
# endif
@@ -964,7 +962,7 @@ struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT>
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
}
};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
// Note due to how libc++'s formatters are implemented there is no need to add
// the exposition only local-time-format-t abstraction.
template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>
@@ -977,13 +975,13 @@ struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public _
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
}
};
-# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
# endif // if _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
-#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+#endif // _LIBCPP_HAS_LOCALIZATION
#endif // _LIBCPP___CHRONO_FORMATTER_H
diff --git a/libcxx/include/__chrono/high_resolution_clock.h b/libcxx/include/__chrono/high_resolution_clock.h
index 0697fd2de9b4de..d324c7f0283bfe 100644
--- a/libcxx/include/__chrono/high_resolution_clock.h
+++ b/libcxx/include/__chrono/high_resolution_clock.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono {
-#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+#if _LIBCPP_HAS_MONOTONIC_CLOCK
typedef steady_clock high_resolution_clock;
#else
typedef system_clock high_resolution_clock;
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
index 3420fb12bcdb0b..ca6d1605d0f87e 100644
--- a/libcxx/include/__chrono/ostream.h
+++ b/libcxx/include/__chrono/ostream.h
@@ -12,7 +12,7 @@
#include <__config>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#if _LIBCPP_HAS_LOCALIZATION
# include <__chrono/calendar.h>
# include <__chrono/day.h>
@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
else if constexpr (same_as<typename _Period::type, nano>)
return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
else if constexpr (same_as<typename _Period::type, micro>)
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# if _LIBCPP_HAS_UNICODE
return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
# else
return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
@@ -307,7 +307,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {
_LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);
}
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {
@@ -322,6 +322,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _Ti
_LIBCPP_END_NAMESPACE_STD
-#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+#endif // _LIBCPP_HAS_LOCALIZATION
#endif // _LIBCPP___CHRONO_OSTREAM_H
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index c9cfcc6d572f41..3976864c12b983 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -12,7 +12,7 @@
#include <__config>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#if _LIBCPP_HAS_LOCALIZATION
# include <__format/concepts.h>
# include <__format/format_error.h>
@@ -416,6 +416,6 @@ class _LIBCPP_TEMPLATE_VIS __parser_chrono {
_LIBCPP_END_NAMESPACE_STD
-#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#endif // _LIBCPP_HAS_LOCALIZATION
#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
diff --git a/libcxx/include/__chrono/statically_widen.h b/libcxx/include/__chrono/statically_widen.h
index 680483a59ac2c4..40e085633b8c16 100644
--- a/libcxx/include/__chrono/statically_widen.h
+++ b/libcxx/include/__chrono/statically_widen.h
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# if _LIBCPP_HAS_WIDE_CHARACTERS
template <__fmt_char_type _CharT>
_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {
if constexpr (same_as<_CharT, char>)
@@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s
return __wstr;
}
# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
-# else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# else // _LIBCPP_HAS_WIDE_CHARACTERS
// Without this indirection the unit test test/libcxx/modules_include.sh.cpp
// fails for the CI build "No wide characters". This seems like a bug.
@@ -43,7 +43,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s
return __str;
}
# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
-# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# endif // _LIBCPP_HAS_WIDE_CHARACTERS
#endif // _LIBCPP_STD_VER >= 20
diff --git a/libcxx/include/__chrono/steady_clock.h b/libcxx/include/__chrono/steady_clock.h
index 612a7f156e6343..1b247b2c286094 100644
--- a/libcxx/include/__chrono/steady_clock.h
+++ b/libcxx/include/__chrono/steady_clock.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono {
-#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+#if _LIBCPP_HAS_MONOTONIC_CLOCK
class _LIBCPP_EXPORTED_FROM_ABI steady_clock {
public:
typedef nanoseconds duration;
diff --git a/libcxx/include/__chrono/time_zone.h b/libcxx/include/__chrono/time_zone.h
index de11dac1eef0c2..3bfe482a146244 100644
--- a/libcxx/include/__chrono/time_zone.h
+++ b/libcxx/include/__chrono/time_zone.h
@@ -37,8 +37,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
namespace chrono {
@@ -170,8 +169,8 @@ operator<=>(const time_zone& __x, const time_zone& __y) noexcept {
} // namespace chrono
-# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
- // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# endif // _LIBCPP_STD_VE...
[truncated]
|
131d843
to
e27bca3
Compare
e27bca3
to
d80d1d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM w/ CI green.
d80d1d9
to
3a189c3
Compare
This caused a surprising issue in external code that is checking these libcxx config macros. Is this change slated to be backported to 19.x, or is this strictly for 20.x development going forward? Since b4130be (#109525) we have code in compiler-rt/libfuzzer, which tries to check the kind of thread API used for c++ threads, by doing #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_GLIBCXX_GCC_GTHR_POSIX_H) Admittedly, this is known to not be a supported construct. (CC @Zentrik) Now after this change, we suddenly end up picking this pthread codepath every time. The way forward of fixing this, is to extend the condition like this: #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && _LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_GLIBCXX_GCC_GTHR_POSIX_H) However with the previous form, we'd have #define _LIBCPP_HAS_THREAD_API_PTHREAD where the macro expands to nothing (contrary to If we try doing that with the new form of the ifdef, we end up with this error:
Do you see any way of adjusting the If not, I'm afraid that we'd need to rip out the libc++ specific part of #109525, or entirely skip setting the thread names in libfuzzer on mingw targets. |
As you mentioned, checking libc++ internal macros is not something we support. If we supported that, we couldn't make any modifications to the code base without breaking people. Perhaps you could do something along those lines instead? if constexpr (std::is_same_v<std::thread::native_handle_type, pthread_t>) {
// assume pthread
} |
Hmm, but that expression can't be compiled at all, if the type |
Yep - I guess this is a case of us thinking "how bad can it be" (https://xkcd.com/292/). I guess I assumed that if things change/break (e.g. if the macro is renamed) we'd fail by not picking up libcxx built with pthreads (which, TBH, is a very rare configuration - I think this was added to work with libstdc++ builds on top of pthread, which is a very common configuration). I.e. we assumed that if things break, we'd get false negatives, but instead we get false positives for the condition here. |
Here's what I would suggest: #if __has_include(<pthread.h>)
#include <pthread.h>
inline void maybe_set_thread_name(std::thread& t, std::string const& name) {
if constexpr (std::is_same_v<std::thread::native_handle_type, ::pthread_t>) {
(void)pthread_setname_np(t.native_handle(), name.c_str());
}
}
#else
inline void maybe_set_thread_name(std::thread& t, std::string const& name) {
// don't even try
}
#endif |
Thanks - that might indeed work. As the other alternative is to set the thread name with win32 threads, we could also check for that data type - assuming that Although - I'm potentially leaning towards simply skipping this entirely for mingw, as this is used in libfuzzer which isn't even usable in mingw contexts yet (libfuzzer gets compiled but clang doesn't let you use it); no need to bend over backwards for quality of life improvements for such a configuration. |
That's your call! |
FWIW, that setup with
I posted a PR to simply skip this on mingw targets, in #115167. |
@mstorsjo I think the problem is that your if condition isn't dependent. I think something like this would fix it: template <class Thread>
void maybe_set_thread_name(Thread& t, std::string const& name) {
if constexpr (std::is_same_v<typename Thread::native_handle_type, ::pthread_t>) {
(void)pthread_setname_np(t.native_handle(), name.c_str());
}
} This might be worth trying out. |
Thanks! With that form, I did manage to seemingly get it to work. I've posted such a solution for future reference, but I think we'll steer clear of that for practical reasons for now. But if we want to go down that route - we now have a proper solution. Thanks! |
…m#115774) Noticed this while debugging a few things following llvm#112094. Amended error message to reflect conditional check.
…ng unstable false due to changes in llvm llvm/llvm-project#112094
…e keeping unstable false due to changes in llvm llvm/llvm-project#112094
* chore: bump chromium in DEPS to 133.0.6858.0 * chore: bump chromium in DEPS to 133.0.6860.0 * chore: update patches v8/revert_fastapi_remove_dynamic_overload_resolution.patch had some additions due to https://chromium-review.googlesource.com/c/v8/v8/+/6023139 * 6044060: Reland "Moves shared GN templates into //build/config/apple." https://chromium-review.googlesource.com/c/chromium/src/+/6044060 * Revert "6023139: [fastapi] Add support for attribute setters" https://chromium-review.googlesource.com/c/v8/v8/+/6023139 * Update printing.patch The removed include is present in the original source file now, just slightly before where it was being added. 6015430: Reduce platform-like buildflags in sandbox code Refs: https://chromium-review.googlesource.com/c/chromium/src/+/6015430 * 6039836: Migrate Command::IsMediaKey to be a member of ui::Accelerator https://chromium-review.googlesource.com/c/chromium/src/+/6039836 * 6038659: [CodeHealth] Clean up the feature ZstdContentEncoding https://chromium-review.googlesource.com/c/chromium/src/+/6038659 * chore: bump chromium in DEPS to 133.0.6862.0 * chore: update patches * 72747: crypto: switch to C++ https://boringssl-review.googlesource.com/c/boringssl/+/72747 * fixup! 72747: crypto: switch to C++ https://boringssl-review.googlesource.com/c/boringssl/+/72747 * chore: gen libc++ filenames * 6042601: [shared storage] Implement with_lock option for methods from response headers https://chromium-review.googlesource.com/c/chromium/src/+/6042601 * chore: bump chromium in DEPS to 133.0.6864.0 * chore: bump chromium in DEPS to 133.0.6866.0 * chore: bump chromium in DEPS to 133.0.6868.0 * chore: bump chromium in DEPS to 133.0.6870.0 * chore: bump chromium in DEPS to 133.0.6872.0 * chore: bump chromium in DEPS to 133.0.6874.0 * chore: bump chromium in DEPS to 133.0.6876.0 * 6039992: Fix false activation logic for context menu. | https://chromium-review.googlesource.com/c/chromium/src/+/6039992 * chore: update patches * chore: update patches * chore: bump chromium in DEPS to 133.0.6878.0 * chore: update patches * [Build] Organize //components/dbus into a single component Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6055280 * Merge //components/dbus/* into a single //components/dbus, which matches how most components are organized. This avoids having many small shared libraries which incurs unnecessary overhead. * Limit visibility of //components/dbus/* to //components/dbus * fixup! Update _LIBCPP_ABI_VERSION to always have a default value while keeping unstable false due to changes in llvm llvm/llvm-project#112094 * 6040416: Let s know which widget the input came on. | https://chromium-review.googlesource.com/c/chromium/src/+/6040416 * 6056267: [MPArch guest view] Fix authentication for MPArch guests | https://chromium-review.googlesource.com/c/chromium/src/+/6056267 * make_span() is deprecated: https://issues.chromium.org/issues/341907909 * fixup: https://issues.chromium.org/issues/341907909 * chore: delete extra bracket from removing make_span commit * fixup: 6059305: Make WTF::UTF8ConversionMode a scoped enum | https://chromium-review.googlesource.com/c/chromium/src/+/6059305 * 6051058: CookieInclusionStatus: Remove ctors which bypass invariants | https://chromium-review.googlesource.com/c/chromium/src/+/6051058 * 6038981: Remove most remaining CHECK(false)s | https://chromium-review.googlesource.com/c/chromium/src/+/6038981 * build: use third_party/simdutf in Node.js * chore: node ./script/gen-libc++-filenames.js * chore: fix strict-cast conversion error in subspan() Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6044946 * chore: fix strict-cast conversion error in base::as_bytes() Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6044946 * chore: fix strict-cast conversion error in span.split_at() Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6044946 * chore: use shorthand target name * chore: better docs in build_add_public_config_simdutf_config.patch --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: clavin <[email protected]> Co-authored-by: alice <[email protected]> Co-authored-by: Charles Kerr <[email protected]>
This is a follow-up to #89178. This updates the
<__config_site>
macros.